#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define fst first
#define scd second
const int MAXN=1e5+10,MAXL=1e6+10;
struct phlcs
{
    int d;
    int v,a;
};
phlcs car[MAXN];
int plce[MAXN];
ll hsh[MAXN];
ll cnt[MAXL];
priority_queue<pii,vector<pii>,greater<pii> > rge;
int n,m,L,V;
ll sum;
ll kep;
void init()
{
    kep=sum=0;
    for(int i=0;i<=L;i++)
    {
        cnt[i]=hsh[i]=0;
    }
}
void tot_it()
{
    for(int i=1;i<=m;i++)
    {
        hsh[plce[i]]++;
    }
    cnt[0]=hsh[0];
    for(int i=1;i<=L;i++)
    {
        cnt[i]=cnt[i-1]+hsh[i];
    }
}
void solve()
{
    for(int i=1;i<=n;i++)
    {
        int vel=car[i].v,ar=car[i].a;
        int lft,rght;
        bool flag=false;
        if(ar == 0 && vel > V)
        {
            flag=true;
            lft=car[i].d;
            rght=L;
        }
        if(ar < 0 && vel > V)
        {
            flag=true;
            lft=car[i].d;
            rght=(vel*vel-V*V)/(2*(-ar))+lft;
        }
        if(ar > 0 && vel*vel+2*ar*(L-car[i].d) > V*V)
        {
            flag=true;
            int res=0;
            if(V*V-vel*vel > 2*ar && (V*V-vel*vel)%(2*ar) > 0) res=1;
            if(vel > V) lft=car[i].d;
            else lft=(V*V-vel*vel)/(2*ar)+res+car[i].d;
            rght=L;
        }
        if(flag && (lft > 0 && cnt[rght]-cnt[lft-1] > 0 || lft == 0 && cnt[rght] > 0))
        {
            //cout<<i<<':'<<lft<<','<<rght<<endl;
            sum++;
            pii in;
            in.fst=lft; in.scd=rght;
            rge.push(in);
        }
    }
}
void merge_it()
{
    while(!rge.empty())
    {
        pii now=rge.top(); rge.pop();
        if(rge.empty())
        {
            kep++;
            break;
        }
        pii nxt=rge.top();
        int l1=now.fst,l2=nxt.fst,r1=now.scd,r2=nxt.scd;
        int lft,rght;
        bool flag=false;
        if(l1 <= l2 && r2 <= r1)
        {
            flag=true;
            lft=l2,rght=r2;
        }
        else if(r1 >= l2)
        {
            flag=true;
            lft=l2,rght=r1;
        }
        if(flag && (lft > 0 && cnt[rght]-cnt[lft-1] > 0 || lft == 0 && cnt[rght] > 0))
        {
            rge.pop();
            pii in;
            in.fst=lft; in.scd=rght;
            rge.push(in);
        }
        else kep++;
    }
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int T;
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
        {
            cin>>car[i].d>>car[i].v>>car[i].a;
            //cout<<car[i].d<<' '<<car[i].v<<' '<<car[i].a<<endl;
        }
        for(int i=1;i<=m;i++)
        {
            cin>>plce[i];
        }
        init();
        tot_it();
        solve();
        merge_it();
        cout<<sum<<' '<<m-kep<<endl;
    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 ‐2
6 4 ‐4
2 5 8 9 15

3 3
*/
